package com.rap.modules.sys.user;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.rap.common.annotation.MetaData;
import com.rap.common.entity.AuditableEntity;

@MetaData(value = "用户信息")
@Entity
@Table(name = "sys_user")
@DynamicInsert @DynamicUpdate
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class UserEntity extends AuditableEntity {
	private static final long serialVersionUID = 1L;
	@MetaData(value = "登录名")
	@Column(nullable = false,unique=true, length = 20)
	private String loginName;
	
	@Column(nullable = false, length = 100)
	@MetaData(value = "用户名")
	private String userName;
	
	@MetaData(value = "用户类型" ,enumType="UserType")
	@Column(nullable = false)
	private Integer userType=1;
	@Transient
	@JsonIgnore
	private String plainPassword;
	@JsonIgnore
	private String password;
	private String pwdPolicy;
	private String salt;
	
	@MetaData(value = "最后登录时间")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+08:00")
	private Date lastLoginTime;
	
	@MetaData(value = "最后登录IP")
	@Column(length = 50)
	private String lastLoginIP;
	private String portrait;
	
	@MetaData(value = "生效日期")
	@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+08:00")
	private Date validDate;
	
	@MetaData(value = "失效日期")
	@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+08:00")
	private Date invalidDate;
	
	private String pwdProblem;
	private String pwdAnswer;
	private String description;
	
	@MetaData(value = "显示顺序")
	private Integer showOrder;
	
	@MetaData(value = "所属单位Id")
	@Column(length=50)
	private String orgId;
	
	@MetaData(value = "所属单位名称")
	@Column(length=256)
	private String orgName;
	
	@MetaData(value = "人员编码")
	@Column(length=50)
	private String personId;
	
	@MetaData(value = "关联人员名称")
	@Column(length=256)
	private String personName;
	
	@MetaData(value = "部门编码")
	@Column(length=50)
	private String deptId;
	
	@MetaData(value = "部门名称")
	@Column(length=256)
	private String deptName;
	
	//序列码
	@Column(length=128)
	private String serialNumber;
	
	@MetaData(value = "组别一编码")
	@Column(length=256)
	private String groupOneCodes;
	@MetaData(value = "组别一名称")
	@Column(length=256)
	private String groupOneNames;
	@MetaData(value = "组别二编码")
	@Column(length=256)
	private String groupTwoCodes;
	@MetaData(value = "组别二名称")
	@Column(length=256)
	private String groupTwoNames;
	
	public String getLoginName() {
		return loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}
	public Integer getUserType() {
		return userType;
	}

	public void setUserType(Integer userType) {
		this.userType = userType;
	}

	public String getPlainPassword() {
		return plainPassword;
	}

	public void setPlainPassword(String plainPassword) {
		this.plainPassword = plainPassword;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getPwdPolicy() {
		return pwdPolicy;
	}

	public void setPwdPolicy(String pwdPolicy) {
		this.pwdPolicy = pwdPolicy;
	}

	public String getSalt() {
		return salt;
	}

	public void setSalt(String salt) {
		this.salt = salt;
	}

	public Date getLastLoginTime() {
		return lastLoginTime;
	}

	public void setLastLoginTime(Date lastLoginTime) {
		this.lastLoginTime = lastLoginTime;
	}

	public String getLastLoginIP() {
		return lastLoginIP;
	}

	public void setLastLoginIP(String lastLoginIP) {
		this.lastLoginIP = lastLoginIP;
	}

	public String getPortrait() {
		return portrait;
	}

	public void setPortrait(String portrait) {
		this.portrait = portrait;
	}

	
	public Date getValidDate() {
		return validDate;
	}

	public void setValidDate(Date validDate) {
		this.validDate = validDate;
	}

	public Date getInvalidDate() {
		return invalidDate;
	}

	public void setInvalidDate(Date invalidDate) {
		this.invalidDate = invalidDate;
	}

	public String getPwdProblem() {
		return pwdProblem;
	}

	public void setPwdProblem(String pwdProblem) {
		this.pwdProblem = pwdProblem;
	}

	public String getPwdAnswer() {
		return pwdAnswer;
	}

	public void setPwdAnswer(String pwdAnswer) {
		this.pwdAnswer = pwdAnswer;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Integer getShowOrder() {
		return showOrder;
	}

	public void setShowOrder(Integer showOrder) {
		this.showOrder = showOrder;
	}

	public String getOrgId() {
		return orgId;
	}

	public void setOrgId(String orgId) {
		this.orgId = orgId;
	}

	public String getOrgName() {
		return orgName;
	}

	public void setOrgName(String orgName) {
		this.orgName = orgName;
	}

	public String getPersonId() {
		return personId;
	}

	public void setPersonId(String personId) {
		this.personId = personId;
	}

	public String getPersonName() {
		return personName;
	}

	public void setPersonName(String personName) {
		this.personName = personName;
	}
	
	

	public String getDeptId() {
		return deptId;
	}

	public void setDeptId(String deptId) {
		this.deptId = deptId;
	}

	public String getDeptName() {
		return deptName;
	}

	public void setDeptName(String deptName) {
		this.deptName = deptName;
	}

	public String toString(){
		return this.userName;
	}

	public String getSerialNumber() {
		return serialNumber;
	}

	public void setSerialNumber(String serialNumber) {
		this.serialNumber = serialNumber;
	}

	public String getGroupOneCodes() {
		return groupOneCodes;
	}

	public void setGroupOneCodes(String groupOneCodes) {
		this.groupOneCodes = groupOneCodes;
	}

	public String getGroupOneNames() {
		return groupOneNames;
	}

	public void setGroupOneNames(String groupOneNames) {
		this.groupOneNames = groupOneNames;
	}

	public String getGroupTwoCodes() {
		return groupTwoCodes;
	}

	public void setGroupTwoCodes(String groupTwoCodes) {
		this.groupTwoCodes = groupTwoCodes;
	}

	public String getGroupTwoNames() {
		return groupTwoNames;
	}

	public void setGroupTwoNames(String groupTwoNames) {
		this.groupTwoNames = groupTwoNames;
	}
	
	
	
}
